<?php

class Profiles extends CActiveRecord
{
	/**
	 * The followings are the available columns in table 'profiles':
	 * @var integer $profiles_id
	 * @var integer $profiles_users_id
	 * @var string $profiles_name
	 * @var string $profiles_firstname
	 * @var string $profiles_email
	 * @var string $profiles_created_at
	 * @var string $profiles_changed_at
	 * @var string $profiles_deleted_at
	 */

	/**
	 * Returns the static model of the specified AR class.
	 * @return CActiveRecord the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'profiles';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('profiles_users_id, profiles_created_at, profiles_changed_at', 'required'),
			array('profiles_users_id', 'numerical', 'integerOnly'=>true),
			array('profiles_name, profiles_firstname, profiles_email', 'length', 'max'=>45),
			array('profiles_deleted_at', 'safe'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'profiles_users' => array(self::BELONGS_TO, 'Users', 'profiles_users_id'),
			'companys' => array(self::MANY_MANY, 'Companys', 'profiles_has_companys(profiles_has_companys_id, profiles_has_companys_companys_id)'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'profiles_id' => Yii::t('crm', 'ID'),
			'profiles_users_id' => Yii::t('crm', 'Nutzer'),
			'profiles_name' => Yii::t('crm', 'Nachname'),
			'profiles_firstname' => Yii::t('crm', 'Vorname'),
			'profiles_email' => Yii::t('crm', 'E-Mail-Adresse'),
			'profiles_created_at' => Yii::t('crm', 'Erstellt'),
			'profiles_changed_at' => Yii::t('crm', 'Geändert'),
			'profiles_deleted_at' => Yii::t('crm', 'Gelöscht'),
		);
	}
}